@extends('admin.layout')
@section('body')

    <!-- 正文开始 -->
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 表格工具栏 -->
                <form class="layui-form toolbar" id="formSearch">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">@lang('common.keyword'):</label>
                            <div class="layui-input-inline">
                                <input name="keyword" class="layui-input"
                                       placeholder="@lang('system.user.keyword_placeholder')"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">@lang('system.user.role'):</label>
                            <div class="layui-input-inline">
                                @include('admin.system.widget.role_select',['widget_params'=>['all'=>true]])
                            </div>
                        </div>
                        <div class="layui-inline">&emsp;
                            <button class="layui-btn icon-btn" lay-filter="searchForm" lay-submit>
                                <i class="iconfont icon-ic_search"></i>@lang('common.search')
                            </button>
                        </div>
                    </div>
                </form>
                <!-- 数据表格 -->
                <table id="adminTable" lay-filter="adminTable"></table>
            </div>
        </div>
    </div>
@stop

@push('script')
    <script type="text/javascript">
        layui.use(['layer', 'form', 'table', 'util', 'admin', 'laydate'], function () {
            var $ = layui.jquery, form = layui.form, laydate = layui.laydate;
            //日期范围选择
            laydate.render({
                elem: '#dateCreateTimeRange',
                range: '~' //或 range: '~' 来自定义分割字符
            });
            laydate.render({
                elem: '#dateLoginTimeRange',
                range: '~' //或 range: '~' 来自定义分割字符
            });
            let rowBarWidth = 30;
            //加载完成
            var listTableInc = new ListTable("{{admin_url($baseRoute.'pager')}}");
            @auth('create')
            listTableInc.topAddBar("{{admin_url($baseRoute.'create')}}", {
                title: "@lang('common.create')",
                area: ['700px', '385px'],
                success: function (layero, index) {
                    SystemUtil.popViewSet(index);
                }
            });
            @endauth
            @auth('edit')
            listTableInc.editBar((tb, d) => {
                SystemUtil.openUrl2({
                    content: "{{admin_url($baseRoute.'edit')}}/" + d.id,
                    title: "@lang('common.edit')",
                    area: ['650px', '385px'],
                    success: function (layero, index) {
                        SystemUtil.popViewSet(index);
                    }
                });
                SystemUtil.CurrentTableInc = tb;
            });
            rowBarWidth += 60;
            @endauth
            @auth('setPassword')
            listTableInc.actionBar('<button type="button" class="layui-btn layui-btn-normal layui-btn-xs"  title="设置密码">设置密码</button>', (tb, d) => {
                SystemUtil.openUrl2({
                    content: "{{admin_url($baseRoute.'setPassword')}}/" + d.id,
                    title: "设置密码",
                    area: ['400px', '250px']
                });
                SystemUtil.CurrentTableInc = tb;
            });
            rowBarWidth += 85;
            @endauth

            @auth('delete')
            listTableInc.topBatchDeleteBar("{{admin_url($baseRoute.'batchDelete')}}");
            listTableInc.delBar(function (tb, d) {
                return SystemUtil.ajax("{{admin_url($baseRoute.'delete')}}").setData({id: d.id});
            });
            rowBarWidth += 60;
            @endauth
            {{--            @auth('recharge')--}}
            {{--            listTableInc.actionBar('<a class="table-btn" title="充值">充值</a>', (tb, d) => {--}}
            {{--                SystemUtil.openUrl2({--}}
            {{--                    content: "{{admin_url($baseRoute.'recharge')}}/" + d.id,--}}
            {{--                    title: "充值",--}}
            {{--                    area: ['400px', '200px']--}}
            {{--                });--}}
            {{--                SystemUtil.CurrentTableInc = tb;--}}
            {{--            });--}}
            {{--            rowBarWidth += 60;--}}
            {{--            @endauth--}}
            listTableInc.checkbox();
            listTableInc.lineNumber();
            listTableInc.column("@lang('common.id')", "id").setWidth(100);
            listTableInc.column("@lang('system.user.username')", "username");
            listTableInc.column("手机号", "mobile");
            listTableInc.column("@lang('system.user.role_name')", "role_name");
            listTableInc.column("注册时间", "created_at").setWithDateTime();
            listTableInc.rowBarWidth = rowBarWidth;
            listTableInc.render();
        });
    </script>
@endpush
